package cn.wolfcode.trip.admin.controller;


import cn.wolfcode.trip.base.util.UploadUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/image")
public class ImageController {


    @RequestMapping("/upload")
    @ResponseBody
    public Object upload(@RequestParam MultipartFile upload) {
        //把上传的图片保存到本地图库
        String url = UploadUtil.upload(upload);
        //并且把图片的地址返回
        Map<String, Object> map = new HashMap<>();
        map.put("url", url);
        map.put("upload", 1);
        return map;
    }
}
